  <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.tt.shpping.*,com.tt.DAO.*" %>
 <%
 request.setCharacterEncoding("utf-8");
 String strPid = request.getParameter("pid");
 int pid =0;
 if(strPid != null ) {
	 pid = Integer.parseInt(strPid);   
 }
 String action = request.getParameter("action");
 if(action!=null && action.trim().equals("add")){
	 String name = request.getParameter("name");
	 String descr = request.getParameter("descr");
	 if(pid == 0) {
		 CategoryDAO.addTopCategory(name, descr); 
	 }else {
		 CategoryDAO.addChildCategory(name, descr,pid);
	 }
	
	 out.print("保存成功");
 }
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<center>添加类别</center>
<form action="categoryAdd.jsp" method="post" >
	<input type="hidden" name="action" value="add">
	<input type="hidden" name="pid" value="<%=pid%>">
	<table border="1">
		<tr>
			<td>类别名称</td>
			<td><input type="text" name="name"/></td>
		</tr>
		<tr>
			<td>类别描述</td>
			<td><textarea rows="8" cols="40" name="descr"></textarea></td>
		</tr>
		<tr>
			<td colspan=2><input type="submit" value="提交"></td>
		</tr>
	</table>
</form>
</body>
</html>